﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using AmazeUI.bll;

using AmazeUI.bll.Open;
using Ema.Filters;
using Ema.Models.XtModel;

namespace Ema.Controllers
{
    public class ArticleController : BaseController
    {
        ArticleBll articleBll = new ArticleBll();

        PayBll _payBll = new PayBll();

        [WxValidate]
        public ActionResult Bm()
        {

            return this.View();
        }

        /// <summary>
        /// 文章列表
        /// </summary>
        /// <returns></returns>
        [WxValidate]
        public ActionResult Index()
        {
            var list = this.articleBll.GetArticleList();
            return View(list);
        }
        /// <summary>
        /// 添加活动
        /// </summary>
        /// <returns></returns>

        public ActionResult AddArticle()
        {
            return View();
        }
        /// <summary>
        /// 添加活动
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        [ValidateInput(false)]
        public ActionResult AddArticle(SubArticle model)
        {
            model.XtUserId = 24;
            var id = articleBll.AddArticle(model);
            return this.RedirectToAction("Comment", new { id });
        }

        /// <summary>
        /// 编辑器预览
        /// </summary>
        /// <returns></returns>

        [ValidateInput(false)]
        public ActionResult Yl(string h)
        {
            return this.View(model: h);
        }

        /// <summary>
        /// 评论
        /// </summary>
        /// <returns></returns>
        [WxValidate]
        public ActionResult Comment(int id)
        {
            var model = articleBll.GetArticleModel(id);

            ViewBag.uid = this.GetAdmin.Id;
            return this.View(model);
        }
        /// <summary>
        /// 评论
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        [WxValidate]
        public ActionResult Comment(SubArticleComment model)
        {
            model.XtUserId = this.GetAdmin.Id;
            articleBll.AddArticleComment(model);
            ViewBag.uid = this.GetAdmin.Id;
            return this.RedirectToAction("Comment", new { id = model.ArticleId });
        }
    }
}
